package com.example.demo.controller;


import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Iterator;

@RestController
@RequestMapping("/api/excel")
@Slf4j
public class ExcelController {

    @PostMapping("paper")
    public void mockPager(@RequestParam("file") MultipartFile file){
        try {
            XWPFDocument xwpfDocument=new XWPFDocument(file.getInputStream());
            XWPFParagraph para;
            Iterator<XWPFParagraph> iterable=xwpfDocument.getParagraphsIterator();
            while ((iterable.hasNext())){
                para=iterable.next();
                log.info("输出:{}",para.getText());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



}
